package com.hibernate.util;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import com.sun.org.apache.bcel.internal.generic.ReturnaddressType;

public class HibernateUtil {
	private static SessionFactory sessionFactory;
	static{
		try {
			Configuration configuration = new Configuration();
			configuration.configure("hibernate.cfg.xml");
			sessionFactory = configuration.buildSessionFactory();
		} catch (HibernateException e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
	}
	public static Session getSession(){
		return sessionFactory.openSession();
	}
	
	public static SessionFactory getSessionFactory(){
		return HibernateUtil.sessionFactory;
	}
}
